/*
 * @Author: zhangzhen
 * @Date: 2023-01-03 09:01:54
 * @LastEditors: zhangzhen
 * @LastEditTime: 2023-03-15 18:48:28
 *
 */

import React from 'react';
import {Form, DatePicker} from 'antd';
import moment from 'moment';

import {FormConTextValueType} from '../context';

const FormItem = Form.Item;

const RangePicker: any = DatePicker.RangePicker;

const RangePickerComponent: React.FC<FormConTextValueType> = (props) => {
    const {
        label,
        name,
        rules,
        required,
        infoCome,
        isSearch,
        isShowInTable,
        defaultValue,
        labelSpan,
        ...RangePickerProps
    } = props;

    return (
        <FormItem
        labelCol={{flex: `${labelSpan}px`}}
            label={label}
            name={name}
            rules={rules}
            required={required}
            initialValue={defaultValue?[moment(defaultValue[0]), moment(defaultValue[1])]:[]}>
            <RangePicker {...RangePickerProps} />
        </FormItem>
    );
};

export default RangePickerComponent;
